package com.leetcode.LC;

public class LC405 {
    public String toHex(int num) {
        //无法处理负数
        String rs = "0123456789abcdef";
        if (num < 16) {
            return rs.charAt(num) + "";
        }
        String result = "";
        while (num > 0) {
            result = rs.charAt(num % 16) + result;
            num /= 16;
        }
        if (num<0){
            result="f"+result;
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(new LC405().toHex(-1));
    }
}
